// 模糊匹配函数
const fuzzyMatch = (input, keys) => {
  const inputWords = input.split(' ');
  const keyWords = keys.split(',');
  return inputWords.some(word => keyWords.includes(word));
};

// 查询知识库
export const searchKnowledgeBase = async (question, knowledgeBase) => {
  for (const category in knowledgeBase) {
    const faqs = knowledgeBase[category];
    for (const faq of faqs) {
      if (fuzzyMatch(question, faq.keys)) {
        return faq.content; // 返回匹配的答案
      }
    }
  }
  return null; // 没有匹配到
};